home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5076 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.3 KB

  1. Path: news1.h1.usa.pipeline.com!usenet
  2. From: grantp@usa.pipeline.com(Pete)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Question:  Regards constructors, ptrs. and classes
  5. Date: 2 Feb 1996 12:02:55 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4esuhf$c6v@news1.usa.pipeline.com>
  8. NNTP-Posting-Host: pipe10.h1.usa.pipeline.com
  9. X-PipeUser: grantp
  10. X-PipeHub: usa.pipeline.com
  11. X-PipeGCOS: (Pete)
  12. X-Newsreader: Pipeline USA v3.3.0
  13.  
  14. On Feb 02, 1996 00:49:19 in article <Question:  Regards constructors, ptrs.
  15. and classes>, 'akm@red.seas.upenn.edu (The Killer)' wrote: 
  16.  
  17.  
  18. >Please help!  I am in an S.O.S. situation. 
  19. >Here is the problem: 
  20. >Base class... 
  21. >    class MORTGAGE{ 
  22. >       MORTGAGE(.....blah, MORTGAGE*); 
  23. >    } 
  24. >Derived class: 
  25. >class TRAD_MORTGAGE{ 
  26. >       TRAD_MORTGAGE(....blah, TRAD_MORTGAGE*) 
  27. >    } 
  28. If this is a derived class, your code snippet doesn't say so. 
  29. I assume you have something like: 
  30.   class TRAD_MORTGAGE : public MORTGAGE { .. } 
  31. and the closing semicolons after each class declaration. 
  32.  
  33. >Can I do this: 
  34. >    TRAD_MORTGAGE::TRAD_MORTGAGE(...blah, TRAD_MORTGAGE  
  35. >*ptr):MORTGAGE(...blah, ptr){ 
  36. >} 
  37. Yes, the casting of a pointer from a subclass to its base class is  
  38. trivial and done automatically by the compiler. 
  39.  
  40. -- 
  41. Pete Grant 
  42. Kalevi, Inc. 
  43. Object Oriented Software Development
  44.